package com.chao.search;

/**
 * @author : Rookie
 * @description : 顺序查找
 * @date : 2023/7/3
 */
public class SequenceSearch {

    public static void main(String[] args) {
        int []arr = new int[] {3,8,2,4,1,5,9};
        int target = 1;
        int result = search(arr, target);
        System.out.println(result);
    }

    private static int search(int []arr,int target) {
        int index = -1;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == target) {
                index = i;
                break;
            }
        }
        return index;
    }
}
